package com.yihr.bean;


import com.yihr.bean.valid.UserLoginInterface;
import com.yihr.bean.valid.UserRegisterInterface;
import com.yihr.ext.hv.Password;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;

public class User {
    private long id;

    @NotBlank(message = "用户名不能为空", groups = {UserRegisterInterface.class, UserLoginInterface.class})
    @Size(min = 2, max = 32, message = "用户名长度不符！必须在 {min} 和 {max} 之间",
            groups = {UserRegisterInterface.class, UserLoginInterface.class})
    private String username;


    @Password(message = "密码必须是6~32位数字和字母组合", groups = {UserRegisterInterface.class})
    @Length(min = 32, max = 32, message = "密码长度错误", groups = {UserLoginInterface.class})
    private String password;

    private String salt;

    @NotBlank(message = "email 不能为空", groups = {UserRegisterInterface.class})
    @Email(message = "email 格式错误", groups = {UserRegisterInterface.class})
    private String email;


    private String phone;

    private int state;

    private List<String> roles;


    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", salt=" + salt +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", state=" + state +
                '}';
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }
}
